/*
* Nettle Source File.
* Copyright (C) 2013, Nettle (http://nttl.ru/).
*
* This file is part of NettleMath.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser General Public License
* (LGPL) version 2.1 which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-2.1.html
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* Description:
*
* History:
* Created by Sergey Serb, l-proger@yandex.ru
*/

#ifndef NBezier_h__
#define NBezier_h__

namespace NettleMath{
    template<typename T>
    static inline T linearBezier(float t, const T& v1, const T& v2){
        return (v1 * (1-t)) + (v2 * t);
    }

    template<typename T>
    static inline T quadraticBezier(float t, const T& v1, const T& v2, const T& v3){
        return (linearBezier<T>(t, v1, v2) * (1 - t)) + (linearBezier<T>(t, v2, v3) * (t));
    }

    template<typename T>
    static inline T cubicBezier(float t, const T& v1, const T& v2, const T& v3, const T& v4){
        return (quadraticBezier<T>(t, v1, v2, v3) * (1 - t)) + (quadraticBezier<T>(t, v2, v3, v4) * (t));
    }
}
#endif // NBezier_h__
